Skip to content

fix(rag): honor preformatted answers, render high-yield bold, guard safety caveats + retrieval telemetry#514

Merged
BigSimmo merged 17 commits into
mainfrom
claude/rag-review-improvements-f1bf84
Jul 12, 2026
Merged

fix(rag): honor preformatted answers, render high-yield bold, guard safety caveats + retrieval telemetry#514
BigSimmo merged 17 commits into
mainfrom
claude/rag-review-improvements-f1bf84

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Summary

RAG review pass — safe, offline-provable improvements to how answers are formatted/rendered, plus retrieval observability. No retrieval-ranking, scoring, cache-key, or answer-generation logic was changed.

  • F1 — client honors preformatted. The server exempts deterministic document-support-list and table/visual answers from the prose sanitizer, but the client re-ran it unconditionally and deleted their document names / facility codes on display. The client now mirrors the server contract (answer.preformatted && answer.grounded) via a lossless normalizePreformattedDisplayText, threaded through the display chain (display-text.ts, answer-content.tsx, ClinicalDashboard.tsx, answer-result-surface.tsx, output-panel.tsx, evidence-panels.tsx).
  • F3 — high-yield bold reaches the screen; copy draft is clean. The primary answer renders via <SafeBoldText>, but polishClinicalAnswerProse stripped ** first, so server emphasis (and the verified-vs-unverified number signal) never rendered. Added a display-only preserveBold (the shared server answer-gen path is unchanged) and stopped the copy/paste clinical draft from leaking literal **.
  • F4 — safety caveats can't be truncated away. The compact primary-answer cap now always keeps a fragment carrying a safety signal (withhold/stop/threshold/escalate/…); byte-identical output when none is present.
  • F8 — retrieval telemetry. The terminal lexical RPCs (match_document_chunks_text, match_document_table_facts_text, match_documents_for_query) swallowed RPC errors with no signal; they now record hybrid_rpc_errors before the unchanged return [] (retrieval results byte-identical).
  • F7 — owner-filter drift migration (spec). Read-only live inspection confirmed all 8 primary retrieval RPCs already use the fail-closed retrieval_owner_matches — no live hole; the gap is committed-source reproducibility (fresh rebuilds/previews/DR get the stale fail-open bodies). Because live has diverged forward and this env has no Postgres DSN, the migration is a replay-safe, verified, owner-runnable byte-perfect codification spec (runnable fail-closed truth-table guard + exact pg_get_functiondef dump command). It also flags two non-primary functions still carrying a fail-open inline predicate (match_document_embedding_fields_text, get_related_document_metadata).

Verification

  • Offline gates green: typecheck, lint, format:check, full vitest (1655 passed, 1 skipped), eval:rag:offline (59). (verify:pr-local constituents run individually.)
  • @critical demo answer-flow Playwright test green (exercises the modified plain-answer-response render path).
  • npm run eval:retrieval:quality — 36/36 (belt-and-suspenders; doc_recall@5=1, content_recall@5=1, hit@k=1, content_mrr@10=0.9255, force-embedding failures=0). Confirms F8 did not disturb retrieval.
  • [~] npm run eval:quality -- --rag-only --limit 8 — 7/8 grounded (0.875). The one miss (discharge-documentation) is pre-existing and unrelated to this PR: it fails on grounding (route=extractive, model=none), produced entirely by retrieval-selection/grounding code this PR does not touch (the rag.ts diff is 3 additive telemetry lines that fire only on RPC error, of which there were none). Its expectedFiles is an intentional synthetic alias (eval-document-matching.ts), so it is not a stale-fixture issue. Tracked as a separate clinical-governance calibration follow-up.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use (unchanged; the "Source-only" disclosure and verify-first copy are preserved).
  • No patient-identifiable document workflow was introduced or expanded.
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy) — verified via check:supabase-project.
  • Service-role keys and private document access remain server-only (no change; F8 is server-side telemetry only).
  • Demo/synthetic content remains clearly separated from real clinical sources.
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative (untouched).
  • No clinical decision-support behavior changed — these are display-formatting + observability changes; retrieval ranking and answer generation are unchanged, so no TGA SaMD impact.

Notes

  • The F7 migration is intentionally a verified spec, not a functional schema change — completing it (appending the byte-perfect live RPC bodies) requires the owner's DB connection string and a preview-branch + golden-eval verification before it reaches live.

🤖 Generated with Claude Code

…afety caveats + retrieval telemetry

Client display fixes (offline-proven, no retrieval-ranking impact):
- F1: the client now honors the server `preformatted` flag, so document-support-list
  and table/visual answers are no longer re-mangled by the prose sanitizer on
  display (document names and facility codes were being deleted). Adds a lossless
  normalizePreformattedDisplayText and threads the flag through the display chain.
- F3: high-yield **bold** now reaches the rendered answer via SafeBoldText
  (display-only preserveBold; the shared server answer-gen path is unchanged),
  and the copy/paste clinical draft no longer leaks literal `**`.
- F4: the compact primary-answer cap never drops a safety-signal fragment
  (withhold/stop/threshold/escalate/...); byte-identical when none is present.

Retrieval observability (additive, retrieval results byte-identical):
- F8: lexical RPC errors (match_document_chunks_text, match_document_table_facts_text,
  match_documents_for_query) now record hybrid_rpc_errors telemetry before returning
  empty, instead of silently degrading to zero candidates with no signal.

Infra:
- F7: replay-safe migration documenting the retrieval owner-filter drift with a
  verified, owner-runnable byte-perfect codification procedure. Live already gates
  all 8 primary retrieval RPCs with the fail-closed retrieval_owner_matches; the
  gap is committed-source reproducibility only.

Verification: typecheck, lint, format, full vitest (1655 passed), eval:rag:offline,
and the @critical demo answer-flow E2E all green. Live eval:retrieval:quality 36/36.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@supabase

supabase Bot commented Jul 12, 2026

Copy link
Copy Markdown

Updates to Preview Branch (claude/rag-review-improvements-f1bf84) ↗︎

Deployments Status Updated
Database Sun, 12 Jul 2026 19:03:52 UTC
Services Sun, 12 Jul 2026 19:03:52 UTC
APIs Sun, 12 Jul 2026 19:03:52 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Sun, 12 Jul 2026 19:03:54 UTC
Migrations Sun, 12 Jul 2026 19:03:55 UTC
Seeding Sun, 12 Jul 2026 19:03:57 UTC
Edge Functions Sun, 12 Jul 2026 19:03:58 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Preformatted answer handling now preserves structured content during sanitization and rendering, supports controlled bold-marker retention, protects safety fragments during compaction, strips bold markers from copy text, and records hybrid retrieval RPC failures through search telemetry. A migration adds ownership verification for retrieval RPC codification.

Changes

Answer display handling

Layer / File(s) Summary
Display sanitization contracts
src/components/clinical-dashboard/display-text.ts, src/lib/source-text-sanitizer.ts, tests/display-text.test.ts, tests/source-text-sanitizer.test.ts
Preformatted normalization, optional bold preservation, and bolded sub-bullet handling are implemented and tested.
Answer formatting and safety retention
src/components/clinical-dashboard/answer-content.tsx, src/lib/rag-answer-text.ts, src/lib/answer-render-policy.ts, tests/answer-content.test.ts, tests/rag-answer-text.test.ts, tests/answer-render-policy.test.ts
Answer formatting accepts display options, retains safety-signal fragments beyond compaction limits, and removes bold markers from copy text.
Answer rendering integration
src/components/ClinicalDashboard.tsx, src/components/clinical-dashboard/answer-result-surface.tsx, src/components/clinical-dashboard/evidence-panels.tsx, src/components/clinical-dashboard/output-panel.tsx
Grounded preformatted state is propagated to latest and prior answer surfaces and clinical detail rendering.

Retrieval RPC telemetry

Layer / File(s) Summary
Hybrid RPC error reporting
src/lib/rag.ts, tests/rag-offline-answer.test.ts
Lexical, document, and table-fact RPC failures are recorded through search telemetry, while offline tests inject lexical RPC errors and verify ungrounded fail-closed output.

Retrieval ownership migration

Layer / File(s) Summary
Ownership verification migration
supabase/migrations/20260712000000_forward_codify_retrieval_owner_matches.sql
The migration documents retrieval RPC codification, verifies ownership-match outcomes for fixed UUID inputs, and marks where live RPC bodies are appended.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ClinicalDashboard
  participant sanitizeAnswerDisplayText
  participant NaturalLanguageAnswer
  ClinicalDashboard->>sanitizeAnswerDisplayText: sanitize grounded preformatted text
  ClinicalDashboard->>NaturalLanguageAnswer: pass raw answer and preformatted state
  NaturalLanguageAnswer->>sanitizeAnswerDisplayText: format with preformatted and preserveBold options
Loading

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Verification Claims ❌ Error PR text claims green verification (offline gates, Playwright, evals) but several items are summarized rather than exact “Ran : passed”/“Not run: reason” lines. Rewrite the verification section to list each exact command/check with its outcome, or mark it explicitly as Not run with a reason.
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 70.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (9 passed)
Check name Status Explanation
Title check ✅ Passed The title summarizes the main changes: preformatted answer rendering, bold preservation, safety caveats, and retrieval telemetry.
Description check ✅ Passed The description follows the template with Summary, Verification, Clinical Governance Preflight, and Notes, and includes substantial required details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Generated And Sensitive Files ✅ Passed Changed files are only TS/TSX, tests, and a documented SQL migration; scans found no secrets, logs, caches, build outputs, or local env/artifact files.
Risky Git Or Deployment Actions ✅ Passed Changed files contain no force-push/reset/clean/delete-branch guidance; the migration comment only allows preview-branch apply after verification gates.
Supabase Project And Schema Safety ✅ Passed Only Supabase change is a migration-spec file with comments plus a fail-closed verification DO block; no stale project refs or destructive DDL/DML were added, and the PR documents the migration/saf...
Runtime And Package Manager Integrity ✅ Passed PR only changes answer-formatting and a migration; no package.json, lockfile, or .npmrc changes. Repo still pins npm@11.17.0/node24 with engine-strict=true.
Api Route Failure Handling ✅ Passed RPC failures in the changed search paths are recorded and converted to empty results; the new offline test confirms the lexical RPC error path stays fail-closed.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/rag-review-improvements-f1bf84
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/rag-review-improvements-f1bf84

Comment @coderabbitai help to get the list of available commands.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 12, 2026 15:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e87c446854

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/clinical-dashboard/answer-content.tsx Outdated
coderabbitai[bot]
coderabbitai Bot previously requested changes Jul 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/clinical-dashboard/answer-content.tsx (1)

231-292: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Head fragments can still lose safety cues primaryAnswerDisplayText only rescues safetyTail; if a safety cue appears in one of the first 3 fragments after word 85, truncation still drops it. Add a regression test in tests/rag-answer-text.test.ts for a long head fragment containing withhold/do not, and preserve safety-bearing head content when applying the cap.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/clinical-dashboard/answer-content.tsx` around lines 231 - 292,
The 85-word truncation in primaryAnswerDisplayText can remove safety signals
from the first three fragments. Update the head-cap logic to preserve
safety-bearing head content, including fragments matching
primaryAnswerSafetySignalPattern, while retaining the existing compact behavior
for non-safety text; add a regression case in rag-answer-text.test.ts covering a
long head fragment containing “withhold” or “do not”.
🧹 Nitpick comments (1)
tests/rag-offline-answer.test.ts (1)

165-185: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the new telemetry contract directly.

This test verifies fail-closed behavior, but it would still pass if recordHybridRpcError stopped recording match_document_chunks_text. Add an assertion at the telemetry or structured-logging boundary for RPC match_document_chunks_text and code 42P01.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/rag-offline-answer.test.ts` around lines 165 - 185, Extend the test
around answerOffline to assert the telemetry or structured-logging boundary
records an RPC error for match_document_chunks_text with code 42P01. Keep the
existing fail-closed assertions unchanged, and use the test’s existing telemetry
capture or spy mechanism rather than only checking the returned answer.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/clinical-dashboard/display-text.ts`:
- Around line 212-218: Update the preformatted branch in
sanitizeAnswerDisplayText so its handling of **bold** markers matches
options.preserveBold, preventing literal Markdown markers when
PriorAnswerTurnSurface renders collapsed text. Pass the preserveBold setting
through normalizePreformattedDisplayText or explicitly strip markers as
appropriate, and add a regression test covering preformatted text with bold
enabled.

In `@src/lib/source-text-sanitizer.ts`:
- Around line 568-571: Update the blood-value guard patterns in source-text
sanitization to recognize bold markers around values, including line-start forms
such as “o **RhD negative**” and label-prefixed forms such as “group/type: o
**Negative**”. Preserve existing non-bold matching and add regression coverage
for both bold cases.

In
`@supabase/migrations/20260712000000_forward_codify_retrieval_owner_matches.sql`:
- Around line 51-55: Append the exact live CREATE OR REPLACE FUNCTION
definitions for all eight retrieval RPCs after the completion marker in the
migration, preserving their current tenancy and sentinel-handling behavior.
Verify the migration contains all eight function definitions before merging.
- Around line 56-65: Update the commented psql query that builds rpc_bodies.sql
so string_agg orders its inputs by p.proname and p.oid, and remove the trailing
outer ORDER BY p.proname. Keep the existing function filtering and aggregation
behavior unchanged.

---

Outside diff comments:
In `@src/components/clinical-dashboard/answer-content.tsx`:
- Around line 231-292: The 85-word truncation in primaryAnswerDisplayText can
remove safety signals from the first three fragments. Update the head-cap logic
to preserve safety-bearing head content, including fragments matching
primaryAnswerSafetySignalPattern, while retaining the existing compact behavior
for non-safety text; add a regression case in rag-answer-text.test.ts covering a
long head fragment containing “withhold” or “do not”.

---

Nitpick comments:
In `@tests/rag-offline-answer.test.ts`:
- Around line 165-185: Extend the test around answerOffline to assert the
telemetry or structured-logging boundary records an RPC error for
match_document_chunks_text with code 42P01. Keep the existing fail-closed
assertions unchanged, and use the test’s existing telemetry capture or spy
mechanism rather than only checking the returned answer.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7474c87f-ee2b-4c19-bea5-60ac243a0764

📥 Commits

Reviewing files that changed from the base of the PR and between 9da527c and e87c446.

📒 Files selected for processing (16)
  • src/components/ClinicalDashboard.tsx
  • src/components/clinical-dashboard/answer-content.tsx
  • src/components/clinical-dashboard/answer-result-surface.tsx
  • src/components/clinical-dashboard/display-text.ts
  • src/components/clinical-dashboard/evidence-panels.tsx
  • src/components/clinical-dashboard/output-panel.tsx
  • src/lib/answer-render-policy.ts
  • src/lib/rag-answer-text.ts
  • src/lib/rag.ts
  • src/lib/source-text-sanitizer.ts
  • supabase/migrations/20260712000000_forward_codify_retrieval_owner_matches.sql
  • tests/answer-render-policy.test.ts
  • tests/display-text.test.ts
  • tests/rag-answer-text.test.ts
  • tests/rag-offline-answer.test.ts
  • tests/source-text-sanitizer.test.ts

Comment thread src/components/clinical-dashboard/display-text.ts
Comment thread src/lib/source-text-sanitizer.ts
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 5 file(s) based on 4 unresolved review comments.

Files modified:

  • src/components/clinical-dashboard/display-text.ts
  • src/lib/source-text-sanitizer.ts
  • supabase/migrations/20260712000000_forward_codify_retrieval_owner_matches.sql
  • tests/display-text.test.ts
  • tests/source-text-sanitizer.test.ts

Commit: d5ab4c38533d94613e527d7ef7cf388c00c14cd0

The changes have been pushed to the claude/rag-review-improvements-f1bf84 branch.

Time taken: 6m 49s

Fixed 5 file(s) based on 4 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Note

Docstrings generation - SKIPPED
Skipped regeneration as there are no new commits. Docstrings already generated for this pull request at #521.

@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex diagnose and fix failing CI test

Docstrings generation was requested by @BigSimmo.

* #514 (comment)

The following files were modified:

* `src/components/ClinicalDashboard.tsx`
* `src/components/clinical-dashboard/answer-content.tsx`
* `src/components/clinical-dashboard/answer-result-surface.tsx`
* `src/components/clinical-dashboard/display-text.ts`
* `src/components/clinical-dashboard/evidence-panels.tsx`
* `src/components/clinical-dashboard/output-panel.tsx`
* `src/lib/answer-render-policy.ts`
* `src/lib/rag-answer-text.ts`
* `src/lib/rag.ts`
* `src/lib/source-text-sanitizer.ts`
@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Testing

  • npx -y node@24 $(which npm) ci
  • npx -y node@24 $(which npm) run test -- tests/rag-answer-text.test.ts --reporter=dot
  • python3 - <<'PY' ... PY — static migration validation confirmed exactly one definition for each of the eight primary retrieval RPCs, helper-based owner checks, and no legacy fail-open owner predicate in appended bodies.
  • git diff --check
  • npx -y node@24 $(which npm) run typecheck
  • npx -y node@24 ./node_modules/eslint/bin/eslint.js src/components/clinical-dashboard/answer-content.tsx tests/rag-answer-text.test.ts --no-error-on-unmatched-pattern

⚠️ Did not run provider-backed Supabase checks because repository instructions require explicit confirmation before live/provider interactions.

View task →

@BigSimmo
BigSimmo disabled auto-merge July 12, 2026 16:41
@BigSimmo
BigSimmo enabled auto-merge (squash) July 12, 2026 16:41
@BigSimmo
BigSimmo disabled auto-merge July 12, 2026 16:52
@BigSimmo
BigSimmo enabled auto-merge (squash) July 12, 2026 16:52
BigSimmo added 2 commits July 13, 2026 01:15
# Conflicts:
#	src/components/clinical-dashboard/answer-content.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71bd4c6cd0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/clinical-dashboard/answer-content.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af8d86117e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/rag-answer-text.ts Outdated
The compact-answer safety loop only rescued fragments that survived the
`.map`/`.filter` usefulness gate, so a short caveat like "Contraindicated in
pregnancy" (7 words, not flagged "useful") was dropped before it could be
preserved. Make the map/filter safety-aware so safety-bearing fragments pass
through untouched, and add regression tests for short and full-word
escalation/contraindication caveats beyond the compact head.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eca2c84f1d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/clinical-dashboard/answer-content.tsx Outdated
BigSimmo and others added 2 commits July 13, 2026 01:45
…it unformatted)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Skip whole-text clinicalProseUsefulness in primaryAnswerDisplayText so
  short safety sentences (Stop/Cease/held) survive to the fragment bypass
- Add held to the safety signal matcher for passive withhold caveats
- Strip catalogue/source artifacts on a de-bolded copy when preserveBold
  is set, then restore surviving emphasis spans
- Restore the 20260712000000 migration stub so the Supabase preview branch
  matches local migration history (verify guard only; RPC bodies deferred)
- Add regression tests for stop/held caveats and bolded catalogue stripping

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex resolve all comments

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Testing

  • ⚠️ npx -y node@24 $(which npm) run test -- tests/answer-content.test.ts tests/rag-answer-text.test.ts --reporter=dot — initially failed because dependencies were not installed (vitest missing from node_modules).
  • npx -y node@24 $(which npm) ci
  • npx -y node@24 $(which npm) run test -- tests/answer-content.test.ts tests/rag-answer-text.test.ts --reporter=dot
  • npx -y node@24 $(which npm) run typecheck
  • git status --short --branch — confirmed clean worktree on branch work.

View task →

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Simplifying code... This may take up to 20 minutes.

@BigSimmo
BigSimmo disabled auto-merge July 12, 2026 18:04
@BigSimmo
BigSimmo enabled auto-merge (squash) July 12, 2026 18:04
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

✅ Created PR with simplified code: #534

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Ping-pong health check failed

@BigSimmo BigSimmo left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

BigSimmo and others added 2 commits July 13, 2026 02:30
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3016507b23

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/clinical-dashboard/answer-content.tsx Outdated
auto-merge was automatically disabled July 12, 2026 18:37

Head branch was pushed to by a user without write access

@BigSimmo
BigSimmo enabled auto-merge (squash) July 12, 2026 18:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ebd2bf717

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/rag-answer-text.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dac19c935b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/clinical-dashboard/answer-content.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99beaecdcb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/clinical-dashboard/answer-content.tsx Outdated
BigSimmo and others added 3 commits July 13, 2026 02:56
- Add 'avoid' to the safety-signal matcher so short avoidance directives
  ('Avoid lithium in pregnancy.') are preserved through usefulness/length
  filtering and the compact cap (Codex review).
- Test the safety matcher against a de-bolded copy of the fragment via a new
  isPrimaryAnswerSafetyFragment helper, so server bold markers inside a phrase
  ('Do **not** administer', 'red **zone**') on the preserveBold path can no
  longer defeat the match and let a caveat be dropped (Codex P1).
- Add regression tests for the avoid directive and the bolded-keyword caveat.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…l directives

Cover must not / should not / will not, discontinue, suspend, never, and 'not
recommended' so short contraindication-style caveats ('Clozapine should not be
used.') are preserved through usefulness/length filtering and the compact cap
(Codex P1). Kept deliberately broad — matching a non-safety fragment only
preserves it verbatim. Adds a should-not regression test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@BigSimmo
BigSimmo merged commit ef096a3 into main Jul 12, 2026
16 checks passed
@BigSimmo
BigSimmo deleted the claude/rag-review-improvements-f1bf84 branch July 13, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants